#The Weekly Script
#load all the libraries you need.
library(ExPosition)

#1) read in the ep.iris data set from ExPosition.
data(ep.iris)

#2) recode each column of the data set with the function you made.
	#Use the following criteria and example.
	#a) Iris set version 1. center and scale the data (look up scale())
	#and use apply() to get the default values from numeric.to.nominal
	iris.v1 <- apply(scale(ep.iris$data),2,numeric.to.nominal)
	
	#b) Iris set version 2. Recode in the following way for all columns.
	#You'll need a loop.
		## below 0.25 quantile are 'LOW'
		## between 0.25 and 0.5 are 'LOW.MID'
		## between 0.5 and 0.75 are 'HIGH.MID'
		## above 0.75 quantile are 'HIGH'
	iris.v2 <- matrix(0,nrow(ep.iris$data),ncol(ep.iris$data))
	rownames(iris.v2) <- rownames(ep.iris$data)
	colnames(iris.v2) <- colnames(ep.iris$data)
	for(i in 1:ncol(ep.iris$data)){
		quantile.values <- quantile(ep.iris$data[,i],probs=c(0.25,0.5,0.75))
		iris.v2[,i] <- as.character(numeric.to.nominal(ep.iris$data[,i],breaks=c(-Inf,quantile.values,Inf),labels=c('LOW','LOW.MID','HIGH.MID','HIGH')))
	}

#3) Double check your answers against mine (see the attached data files)
#load('db.iris.v1.rda')
#load('db.iris.v2.rda')
	##there is a really fast way to know if every value of your version _is equal to_ every value in mine.
#	db.iris.v1 == iris.v1
#	db.iris.v2 == iris.v2	

#4) Run a PCA on the original Iris set -- also use the design matrix available
iris.1 <- epPCA(ep.iris$data,DESIGN=ep.iris$design,make_design_nominal=FALSE)

#5) Run MCA on the recoded Iris set V2
iris.3 <- epMCA(iris.v2,DESIGN=ep.iris$design,make_design_nominal=FALSE)